import request from "@/lib/ajax";
import md5 from 'js-md5'
// 注册
export  const  register = (data) =>{
  return request({
      url: '/api/user/register',
      method:"post",
      data: JSON.stringify({
        id_card: data.id,
        password:md5(data.password),
        phone_number:data.phoneNumber,
        real_name:data.name,
        verify_code:data.verify_code
      })
  })
}

// 获取手机验证码
export const captchaPhone = (number) => {
  return request({
    url:'/api/base/captchaPhone',
    method: 'post',
    data: JSON.stringify({
      number:number
    })
  })
}
// 获取图片验证码
export const getCaptcha = ()=> {
  return request({
    url:'/api/base/captcha',
  })
}
// 登录
export const login = (data) => {
  return request({
    url:'/api/user/login',
    method:"post",
    data: JSON.stringify({
      // password:data.password,
      password:md5(data.password),
      phone_number:data.phone_number,
      verify_code:data.verify_code,
      verify_code_id:data.verify_code_id,
      verify_type: data.verify_type
    })
  })
}
// 修改密码
export const changePassword = (data) => {
  return request({
    url:'/api/user/changeSelfPassword',
    method:"put",
    data: JSON.stringify({
      new_password:md5(data.newPassword),
      password:md5(data.password)
    })
  })
}
// 获取个人信息
export const getInfo = () => {
  return request({
    url:'/api/user/getInformation',
  })
}
// 换绑手机
export const changePhone = (data) => {
  return request({
    url:'/api/user/changePhone',
    method:'put',
    data: JSON.stringify({
      new_phone:data.new_phone,
      verify_code :data.verify_code
    })
  })
}
// 更新个人信息
export const updataInfo = (data) => {
  return request({
    url:'/api/user/updateSelfInfo',
    method:'put',
    data: JSON.stringify({
      nick_name:data.nickName,
      occupation:data.occupation,
    })

  })
}


